// import Cookies from 'js-cookie'
// import { ElMessageBox } from 'element-plus'
import {
  type NavigationGuardNext,
  type RouteLocationNormalized,
  type RouteRecordRaw,
  createRouter,
  createWebHistory,
} from 'vue-router'

export const publicRouter: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/view/login/index.vue'),
  },
  {
    path: '/login',
    component: () => import('@/view/login/index.vue'),
  },
  {
    path: '/register',
    component: () => import('@/view/login/register.vue'),
  },
  {
    path: '/skillsOne',
    component: () => import('@/view/login/skillsOne.vue'),
  },
  {
    path: '/carousel',
    component: () => import('@/view/login/carousel.vue'),
  },
  {
    path: '/peidui',
    component: () => import('@/view/login/peidui.vue'),
  },
  {
    path: '/home',
    component: () => import('@/view/layout/index.vue'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: () => import('@/view/home/index.vue'),
      },
      {
        path: '/projects',
        component: () => import('@/view/projects/index.vue'),
      },
      {
        path: "/calenda",
        component: () => import('@/view/calendar/index.vue'),
      },
      {
        path: '/messenger',
        component: () => import('@/view/messenger/index.vue'),
      },
      {
        path:'/release',
        component: () => import('@/view/release/index.vue'),
      }
    ],
  },
]
export const changeRouter: RouteRecordRaw[] = []
const router = createRouter({
  // history: createWebHashHistory(),
  history: createWebHistory(),
  routes: changeRouter.concat(publicRouter),
})

const whiteList = []

router.beforeEach((to: RouteLocationNormalized, _from: RouteLocationNormalized, next: NavigationGuardNext) => {
  if (whiteList.includes(to.path.split('?')[0])) {
    return next()
  }
  next()
})

export default router
